package com.imay.live.view.custom;

import android.content.Context;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.imay.live.R;
import com.imay.live.utils.GlideUtil;

/**
 * Created by jeaman on 2017/9/20.
 * 直播结束的礼物展示view
 */

public class RoomEndGiftView extends RelativeLayout {
    private ImageView mCoverIv;
    private TextView mPricev;
    private TextView mNameTv;
    private TextView mNumberTv;

    public RoomEndGiftView(Context context) {
        super(context);
        init(context);
    }

    public RoomEndGiftView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public RoomEndGiftView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public RoomEndGiftView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        init(context);
    }

    private void init(Context context) {
        inflate(context, R.layout.view_room_end_gift, this);
        mCoverIv = (ImageView) findViewById(R.id.room_end_gift_iv_cover);
        mPricev = (TextView) findViewById(R.id.room_end_gift_tv_price);
        mNameTv = (TextView) findViewById(R.id.room_end_gift_tv_name);
        mNumberTv = (TextView) findViewById(R.id.room_end_gift_tv_number);
    }

    public void setData(String coverUrl, String name, int charm, int number) {
        GlideUtil.loadImage(mCoverIv, coverUrl, 0);
        mNameTv.setText(name);
        mPricev.setText(getResources().getString(R.string.live_room_end_price, charm));
        mNumberTv.setText(String.valueOf(number));
    }
}
